<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="common/header.jsp"%>
<div class="clearfix"></div>
<div class="row">
  <div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">
      <div class="x_title">
        <h2>修改APP基础信息 <i class="fa fa-user"></i><small>${loginInfo.devname}</small></h2>
             <div class="clearfix"></div>
      </div>
      <div class="x_content">
        <div>  ${errorInfo }</div>
        <form class="form-horizontal form-label-left" action="updateAppInfo" method="post" enctype="multipart/form-data">
          <input type="hidden" name="id" id="id" value="${appInfo.id}">
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">软件名称 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="softwareName" class="form-control col-md-7 col-xs-12" 
               data-validate-length-range="20" data-validate-words="1" 
               name="softwarename" value="${appInfo.softwarename}" required="required"
               placeholder="请输入软件名称" type="text">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">APK名称 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="APKName" type="text" class="form-control col-md-7 col-xs-12" 
              name="apkname" value="${appInfo.apkname}" readonly="readonly">
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">支持ROM <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="supportROM" class="form-control col-md-7 col-xs-12" 
              	name="supportrom" value="${appInfo.supportrom}" required="required"
              	data-validate-length-range="20" data-validate-words="1" 
              	placeholder="请输入支持的ROM" type="text">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">界面语言 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="interfaceLanguage" class="form-control col-md-7 col-xs-12" 
              data-validate-length-range="20" data-validate-words="1"  required="required"
              name="interfacelanguage" value="${appInfo.interfacelanguage}"
              placeholder="请输入软件支持的界面语言" type="text">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="number">软件大小 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="number" id="softwareSize" name="softwaresize" value="${appInfo.softwaresize}" required="required"
              data-validate-minmax="10,500"  placeholder="请输入软件大小，单位为Mb" class="form-control col-md-7 col-xs-12">
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="number">下载次数 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="number" id="downloads" name="downloads" value="${appInfo.downloads}" required="required"
              data-validate-minmax="10,500"  placeholder="请输入下载次数" class="form-control col-md-7 col-xs-12">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12"  for="select">所属平台 <span class="required">*</span></label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="hidden" value="${appInfo.flatformid}" id="fid" />
              <select name="flatformid" id="flatformId" class="form-control" required="required">
                <option value="">请选择</option>
              </select>
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="select">一级分类 <span class="required">*</span></label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="hidden" value="${appInfo.categorylevel1}" id="cl1" />
              <select name="categorylevel1" id="queryCategoryLevel1" class="form-control"  required="required">
                <option>请选择</option>
              </select>
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12"  for="select">二级分类 <span class="required">*</span></label>
            <div class="col-md-6 col-sm-6 col-xs-12">
            	<input type="hidden" value="${appInfo.categorylevel2}" id="cl2" />
              <select name="categorylevel2" id="queryCategoryLevel2" class="form-control"  required="required">
                <option>请选择</option>
              </select>
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="select">三级分类 <span class="required">*</span></label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="hidden" value="${appInfo.categorylevel3}" id="cl3" />
              <select name="categorylevel3" id="queryCategoryLevel3" class="form-control"  required="required">
                <option>请选择</option>
              </select>
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">APP状态 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
            	<input id="statusName" type="text" class="form-control col-md-7 col-xs-12" 
              	name="statusName" value="${appInfo.sname}" readonly="readonly">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">应用简介 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <textarea id="appInfo" name="appInfo" required="required"
              placeholder="请输入本软件的相关信息，本信息作为软件的详细信息进行软件的介绍。" class="form-control col-md-7 col-xs-12">
              ${appInfo.appinfo}</textarea>
            </div>
          </div>
             <div class="item form-group">
               <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">LOGO图片 <span class="required">*</span>
               </label>
               <div class="col-md-6 col-sm-6 col-xs-12">

                 <img src="${pageContext.request.contextPath}/${appInfo.logopicpath}" width="80" height="100" >
                   <%--显示文件的相对路径--%>
                   <input type="text" name="oldPath" value="${appInfo.logopicpath}">
                 <input type="file" class="form-control col-md-7 col-xs-12" name="a_logoPicPath"   id="a_logoPicPath"/>

               </div>
             </div>
          </div>
          <div class="form-group">
            <div class="col-md-6 col-md-offset-3">
            	<c:if test="${appInfo.status == 3}">
            	 	<button id="send" type="submit" name="status" value="1" class="btn btn-success">保存并再次提交审核</button>
            	</c:if>
              <button id="send" type="submit" class="btn btn-success">保存</button>
              <button type="button" class="btn btn-primary" id="back">返回</button>
              <br/><br/>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
<%@include file="common/footer.jsp"%>
<script language="JavaScript">
$(function(){
    //2.发送异步请求加载 平台进行显示
    $.post("${pageContext.request.contextPath}/getFlatform",null,function(data){
        //console.log(data);
        //动态加载下拉列表的选项
        for(var i=0;i<data.length;i++){
            //创建option
            var option=$("<option value='"+data[i].valueid+"'>"+data[i].valuename+"</option>");
            //将option节点添加到下拉列表
            $("#flatformId").append(option);
        }
        //设置下拉列表的选中项
        $("#flatformId").val(${appInfo.flatformid});
    },"json");




    //加载一级分类
    $.post("${pageContext.request.contextPath}/getCategory",null,function(data){
        //console.log(data);
        //动态加载下拉列表的选项
        for(var i=0;i<data.length;i++){
            //创建option
            var option=$("<option value='"+data[i].id+"'>"+data[i].categoryname+"</option>");
            //将option节点添加到下拉列表
            $("#queryCategoryLevel1").append(option);
        }
        //设置下拉列表的选中项  一级分类
        $("#queryCategoryLevel1").val(${appInfo.categorylevel1});
        loadCatetoryLevel2();  //加载二级
    },"json");

    //实现二级联动效果:给一类分类添加下拉列表改变事件,加载对应二级分类
    $("#queryCategoryLevel1").change(loadCatetoryLevel2);
    //加载二级分类
    function loadCatetoryLevel2(){
        //获取一级分类的id
        var parentId=$("#queryCategoryLevel1").val();
        //清空原有的下拉列表项  保留第一项请选择
        $("#queryCategoryLevel2>option:gt(0)").remove();
        $("#queryCategoryLevel3>option:gt(0)").remove();
        if(parentId!="")
        {
            //参数格式:{"请求参数名":值,"请求参数名":值}
            $.post("${pageContext.request.contextPath}/getCategory",{"id":parentId},function(data){
                //console.log(data);
                //动态加载下拉列表的选项
                for(var i=0;i<data.length;i++){
                    //创建option
                    var option=$("<option value='"+data[i].id+"'>"+data[i].categoryname+"</option>");
                    //将option节点添加到下拉列表
                    $("#queryCategoryLevel2").append(option);
                }

                //设置二级分类的下拉列表选中项
                $("#queryCategoryLevel2").val(${appInfo.categorylevel2});
                loadCategoryLevel3();
            },"json");
        }
    }

    //实现二级联动效果:给二类分类添加下拉列表改变事件,加载对应三级分类
    $("#queryCategoryLevel2").change(loadCategoryLevel3);
    //加载三级分类
    function loadCategoryLevel3(){
        //获取一级分类的id
        var parentId=$("#queryCategoryLevel2").val();
        //清空原有的下拉列表项
        $("#queryCategoryLevel3>option:gt(0)").remove();
        if(parentId!="")
        {
            //参数格式:{"请求参数名":值,"请求参数名":值}
            $.post("${pageContext.request.contextPath}/getCategory",{"id":parentId},function(data){
                //console.log(data);
                //动态加载下拉列表的选项
                for(var i=0;i<data.length;i++){
                    //创建option
                    var option=$("<option value='"+data[i].id+"'>"+data[i].categoryname+"</option>");
                    //将option节点添加到下拉列表
                    $("#queryCategoryLevel3").append(option);
                }
                //设置三级分类的下拉列表选中项
                $("#queryCategoryLevel3").val(${appInfo.categorylevel3});
            },"json");
        }
    }


});

</script>